/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



function setTitle(title) {

    var titlehtml = "<h1>" + title + "</h1>";
    $('#title').html(titlehtml);

}
function setContent(content) {

    $('#content').html(content);

}
function setImage(image) {
    var imagehtml = "";
    if (image) {
       imagehtml = "<img src=\"/image/" + image + "\" />";
    }
    $('#image').html(imagehtml);
}


$(document).ready(setTitle(""));

function updateScreen(id) {
    runurl = "/run/"+id
    $.ajax({
        url: runurl,
        context: document.body,
        success: function(data){
            setTitle(data['title'], "");
            setContent(data['content'], "");
            setImage(data['image'], "");
        }
    }
    );
}

$(document).ready(updateScreen(0));
$(document).everyTime(45000, function(i) {
  updateScreen(i);
});